﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Xml;

/// <summary>
/// Summary description for Attendee
/// </summary>
public class Attendees : List<Attendee>
{
    public Attendees(XmlDocument Xml)
    {
        foreach (XmlElement item in Xml.DocumentElement)
        {
            Attendee a = new Attendee(item);
            base.Add(a);
        }
    }
}

public class Attendee
{
    #region Attendee Arguments
    /// <summary>
    /// The event ID.
    /// </summary>
    public int EventId { get; set; }
    /// <summary>
    /// The ticket ID of the purchased ticket.
    /// </summary>
    public int TicketId { get; set; }
    /// <summary>
    /// The quantity of tickets purchased.
    /// </summary>
    public int Quantity { get; set; }
    /// <summary>
    /// The ticket currency, in 3-letter ISO 4217 format (e.g., "USD").
    /// </summary>
    public string Currency { get; set; }
    /// <summary>
    /// The amount paid by the attendee.
    /// </summary>
    public float AmountPaid { get; set; }
    /// <summary>
    /// Attendee Barcode number "EV-0000000-0000000".
    /// </summary>
    public string Barcode { get; set; }
    /// <summary>
    /// The Eventbrite order ID.
    /// </summary>
    public int OrderId { get; set; }
    /// <summary>
    /// The type/status of order (Free Order, PayPal Completed, Pay By Check, etc).
    /// </summary>
    public string OrderType { get; set; }
    /// <summary>
    /// The date and time the event was created, in ISO 8601 format (e.g., "2007-12-31 23:59:59").
    /// </summary>
    public string Created { get; set; }
    /// <summary>
    /// The date and time the event was last modified, in ISO 8601 format (e.g., "2007-12-31 23:59:59").
    /// </summary>
    public string Modified { get; set; }
    /// <summary>
    /// For repeat events only. Date the attendee has selected.
    /// </summary>
    public string EventDate { get; set; }
    /// <summary>
    /// Discount code and amount used by the attendee.
    /// </summary>
    public string Discount { get; set; }
    /// <summary>
    /// Optional notes.
    /// </summary>
    public string Notes { get; set; }
    ///Email address of the attendee.
    public string Email { get; set; }
    ///Prefix of the attendee.
    public string Prefix { get; set; }
    ///First name of the attendee.
    public string FirstName { get; set; }
    ///Last name of the attendee.
    public string LastName { get; set; }
    ///Suffix of the attendee.
    public string Suffix { get; set; }
    ///Home address of the attendee.
    public string HomeAddress { get; set; }
    ///Line 2 of the home address of the attendee.
    public string HomeAddress2 { get; set; }
    ///Home city of the attendee.
    public string home_city { get; set; }
    ///Home postal code of the attendee.
    public string home_postal_code { get; set; }
    ///Home state/province/county of the attendee.
    public string home_region { get; set; }
    ///Home country name of the attendee.
    public string home_country { get; set; }
    ///Home country code of the attendee, in 2-letter ISO 3166 format (e.g., "US").
    public string home_country_code { get; set; }
    ///Home phone of the attendee.
    public string home_phone { get; set; }
    ///Cell phone of the attendee.
    public string cell_phone { get; set; }
    ///Shipping address of the attendee.
    public string ship_address { get; set; }
    ///Line 2 of the shipping address of the attendee.
    public string ship_address_2 { get; set; }
    ///Shipping city of the attendee.
    public string ship_city { get; set; }
    ///Shipping postal code of the attendee.
    public string ship_postal_code { get; set; }
    ///Shipping state/province/county of the attendee.
    public string ship_region { get; set; }
    ///Shipping country name of the attendee.
    public string ship_country { get; set; }
    ///Shipping country code of the attendee, in 2-letter ISO 3166 format (e.g., "US").
    public string ship_country_code { get; set; }
    ///Work address of the attendee.
    public string work_address { get; set; }
    ///Line 2 of the work address of the attendee.
    public string work_address_2 { get; set; }
    ///Work city of the attendee.
    public string work_city { get; set; }
    ///Work postal code of the attendee.
    public string work_postal_code { get; set; }
    ///Work state/province/county of the attendee.
    public string work_region { get; set; }
    ///Work country name of the attendee.
    public string work_country { get; set; }
    ///Work country code of the attendee, in 2-letter ISO 3166 format (e.g., "US").
    public string work_country_code { get; set; }
    ///Work phone of the attendee.
    public string work_phone { get; set; }
    ///Job title of the attendee.
    public string job_title { get; set; }
    ///Company of the attendee.
    public string company { get; set; }
    ///Website link of the attendee.
    public string website { get; set; }
    ///Blog of the attendee.
    public string blog { get; set; }
    ///Gender of the attendee.
    public string gender { get; set; }
    ///Birth date of the attendee.
    public string birth_date { get; set; }
    ///Age of the attendee.
    public string age { get; set; }
    
    #endregion

    /// <summary>
    /// This constructor will create an array of attendees
    /// </summary>
    /// <param name="XmlElement"></param>
    internal Attendee(XmlElement XmlElement)
    {
        CreateAttendee(XmlElement);
    }
    /// <summary>
    /// This constructor will create an attendee
    /// </summary>
    /// <param name="XmlDocument"></param>
    public Attendee(XmlDocument XmlDocument)
    {
        CreateAttendee(XmlDocument.DocumentElement);
    }

    private void CreateAttendee(XmlElement XmlElement)
    {
        foreach (XmlElement item in XmlElement)
        {
            switch (item.Name)
            {
                case "id":
                    this.EventId = Convert.ToInt32(item.InnerText);
                    break;
                case "ticket_id":
                    this.TicketId = Convert.ToInt32(item.InnerText);
                    break;
                case "quantity":
                    this.Quantity = Convert.ToInt32(item.InnerText);
                    break;
                case "currency":
                    this.Currency = item.InnerText;
                    break;
                case "amount_paid":
                    this.AmountPaid = float.Parse(item.InnerText);
                    break;
                case "barcode":
                    this.Barcode = item.InnerText;
                    break;
                case "order_id":
                    this.OrderId = Convert.ToInt32(item.InnerText);
                    break;
                case "order_type":
                    this.OrderType = item.InnerText;
                    break;
                case "created":
                    this.Created = item.InnerText;
                    break;
                case "modified":
                    this.Modified = item.InnerText;
                    break;
                case "event_date":
                    this.EventDate = item.InnerText;
                    break;
                case "discount":
                    this.Discount = item.InnerText;
                    break;
                case "notes":
                    this.Notes = item.InnerText;
                    break;
                case "email":
                    this.Email = item.InnerText;
                    break;
                case "prefix":
                    this.Prefix = item.InnerText;
                    break;
                case "first_name":
                    this.FirstName = item.InnerText;
                    break;
                case "last_name":
                    this.LastName = item.InnerText;
                    break;
                case "suffix":
                    this.Suffix = item.InnerText;
                    break;
                case "home_address":
                    this.HomeAddress = item.InnerText;
                    break;
                case "home_address_2":
                    this.HomeAddress2 = item.InnerText;
                    break;
                case "home_city":
                    this.home_city = item.InnerText;
                    break;
                case "home_postal_code":
                    this.home_postal_code = item.InnerText;
                    break;
                case "home_region":
                    this.home_region = item.InnerText;
                    break;
                case "home_country":
                    this.home_country = item.InnerText;
                    break;
                case "home_country_code":
                    this.home_country_code = item.InnerText;
                    break;
                case "home_phone":
                    this.home_phone = item.InnerText;
                    break;
                case "cell_phone":
                    this.cell_phone = item.InnerText;
                    break;
                case "ship_address":
                    this.ship_address = item.InnerText;
                    break;
                case "ship_address_2":
                    this.ship_address_2 = item.InnerText;
                    break;
                case "ship_city":
                    this.ship_city = item.InnerText;
                    break;
                case "ship_postal_code":
                    this.ship_postal_code = item.InnerText;
                    break;
                case "ship_region":
                    this.ship_region = item.InnerText;
                    break;
                case "ship_country":
                    this.ship_country = item.InnerText;
                    break;
                case "ship_country_code":
                    this.ship_country_code = item.InnerText;
                    break;
                case "work_address":
                    this.work_address = item.InnerText;
                    break;
                case "work_address_2":
                    this.work_address_2 = item.InnerText;
                    break;
                case "work_city":
                    this.work_city = item.InnerText;
                    break;
                case "work_postal_code":
                    this.work_postal_code = item.InnerText;
                    break;
                case "work_region":
                    this.work_region = item.InnerText;
                    break;
                case "work_country":
                    this.work_country = item.InnerText;
                    break;
                case "work_country_code":
                    this.work_country_code = item.InnerText;
                    break;
                case "work_phone":
                    this.work_phone = item.InnerText;
                    break;
                case "job_title":
                    this.job_title = item.InnerText;
                    break;
                case "company":
                    this.company = item.InnerText;
                    break;
                case "website":
                    this.website = item.InnerText;
                    break;
                case "blog":
                    this.blog = item.InnerText;
                    break;
                case "gender":
                    this.gender = item.InnerText;
                    break;
                case "birth_date":
                    this.birth_date = item.InnerText;
                    break;
                case "age":
                    this.age = item.InnerText;
                    break;
                default:
                    break;
            }
        }
    }
}


//answers array
//Array of answers to custom questions with the following structure:

//question_id integer
//The question ID.
//question string
//The label of the question.
//question_type string
//The type of question ("text" or "multiple choice").
//answer_text string
//The answer to the question.